import api from '../api/index.js';

const state = {
    itemId: [],
    list: [],
    rateTags: [],
}

const actions = {
    DetailsLoad(store) {
        api.detailsComment({
            type: 1,
            itemId: store.state.itemId,
            appPlat: "m",
        }).then((data) => {
            console.log(data);
            if (!data.success) {
                return Promise.reject("错误");
            }
            store.commit("setDetailsList", data.data.list);
            store.commit("setDetailsRateTags", data.data.rateTags);

        }).catch((error) => {

        })
    }
}

const mutations = {
    setDetailsItemId(state, nv) {
        state.itemId = nv;
    },
    setDetailsList(state, nv) {
        state.list = nv;
    },
    setDetailsRateTags(state, nv) {
        state.rateTags = nv;
    },
}

export default {
    state,
    actions,
    mutations
}